import { houseInfoBehavior } from "../../../../behaviors/houseInfo";
import api from "../../../../common/api";

// pages/im/com/copy-house-item/copy-house-item.js
Component({
  behaviors: [houseInfoBehavior],

  /**
   * 组件的属性列表
   */
  properties: {
    model: {
      type: Object,
      default: {},
    },
    houdelId: {
      type: String,
      default: "",
    },
  },

  options: {
    styleIsolation: "apply-shared",
    addGlobalClass: true,
  },
  /**
   * 组件的初始数据
   */
  data: {
    model: {},
  },

  
  lifetimes: {
    attached: function () {
      api.getHouseInfo({ houDelId: this.data.houdelId }, ({ data }) => {
        if (!data.isSuccess) return
        const houDelVO = data.content.houDelVO
        houDelVO._priceText = this.getPriceText(houDelVO)
        this.setData({
          model: houDelVO,
        });
      });
    },

    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleShare() {
      console.log("去分享", this.data.houdelId);
      wx.navigateTo({
        url: `/pages/house/RentalHouseDetail/RentalHouseDetail?houdelid=${this.data.houdelId}&from=1&type=${this.data.model.delegationType}`,
      });

    },
  },
});
